# 导入随机模块
from random import choice
# 导入字符串模块
import string
# print(string.ascii_letters + string.digits)
def rand_pass(n):
    # 获取字符串 abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789
    chars = string.ascii_letters + string.digits
    pa = ''
    # 循环获取字符并拼接
    for i in range(n):
        pa += choice(chars)
    return pa
    # 返回 n 位的随机字符串

# 测试
if __name__ == '__main__':
    print(rand_pass(8))
    print(rand_pass(10))
